home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / workbench werkzeuge / bildschirmschoner / bserver_v1.5 / sources.lha / Sources / server / commodity.c < prev    next >
C/C++ Source or Header  |  1995-11-08  |  2KB  |  124 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <libraries/commodities.h>
  4. #include <libraries/gadtools.h>
  5. #include <dos/dos.h>
  6. #include <workbench/startup.h>
  7. #include <stdio.h>
  8. #include <string.h>
  9.  
  10. #include <proto/exec.h>
  11. #include <proto/commodities.h>
  12. #include <proto/gadtools.h>
  13. #include <proto/dos.h>
  14. #include <proto/icon.h>
  15. #include <clib/alib_protos.h>
  16.  
  17. #include "/include/server.h"
  18.  
  19. extern BOOL PopUp, CommodityActive;
  20. extern struct Window *window;
  21. extern UBYTE BlankStatus;
  22.  
  23. extern BOOL PopUpWindow( void );
  24. extern void ShutWindow( void );
  25.  
  26. extern void StartBlanking( void );
  27. extern void Quit( void );
  28.  
  29.  /******************
  30.  *                 *
  31.  * GENERAL UTILITY *
  32.  *                 *
  33.  ******************/
  34.  
  35.  
  36. void ClearPendingMessages( struct MsgPort *mport )
  37. {
  38. struct Message *msg;
  39.  
  40. while ( msg = GetMsg( mport ) )
  41.     ReplyMsg( msg );
  42. }
  43.  
  44.  
  45.  /******************
  46.  *                 *
  47.  * COMMODITY STUFF *
  48.  *                 *
  49.  ******************/
  50.  
  51. struct Library *CxBase, *IconBase;
  52. struct MsgPort *broker_mp;
  53. CxObj *broker, *filter, *sender, *translate;
  54.  
  55. ULONG CXSignal;
  56.  
  57. struct NewBroker newbroker = {
  58.     NB_VERSION,
  59.     PROGRAMNAME,
  60.     PROGRAMNAME" "PROGRAMVERSION" © 1995 by Stefano Reksten",
  61.     "Simple server for screen blankers",
  62.     NBU_UNIQUE | NBU_NOTIFY,
  63.     COF_SHOW_HIDE, 0, 0, 0 };
  64.  
  65.  
  66. UBYTE brokerPri = 0;
  67. char hotkey[40] = "lalt b";
  68.  
  69. void HandleCxMessages( void )
  70. {
  71. CxMsg *msg;
  72. ULONG msgid, msgtype;
  73.  
  74. while(msg = (CxMsg *)GetMsg(broker_mp))
  75.     {
  76.     msgid = CxMsgID(msg);
  77.     msgtype = CxMsgType(msg);
  78.     ReplyMsg((struct Message *)msg);
  79.  
  80.     switch(msgtype)
  81.         {
  82.         case CXM_IEVENT:
  83.             if ( msgid == EVT_HOTKEY )
  84.                 PopUpWindow();
  85.             else if ( msgid == EVT_BLANKKEY && BlankStatus == IDLE )
  86.                 {
  87.                 Delay( 10 );
  88.                 BlankStatus = MUST_BLANK;
  89.                 StartBlanking();
  90.                 }
  91.             break;
  92.  
  93.         case CXM_COMMAND:
  94.             switch(msgid)
  95.             {
  96.             case CXCMD_DISABLE:
  97.                 ActivateCxObj(broker, 0L);
  98.                 CommodityActive = FALSE;
  99.                 break;
  100.             case CXCMD_ENABLE:
  101.                 ActivateCxObj(broker, 1L);
  102.                 CommodityActive = TRUE;
  103.                 break;
  104.             case CXCMD_KILL:
  105.                 Quit();
  106.                 break;
  107.             case CXCMD_UNIQUE:
  108.                 PopUpWindow();
  109.                 break;
  110.             case CXCMD_APPEAR:
  111.                 PopUpWindow();
  112.                 break;
  113.             case CXCMD_DISAPPEAR:
  114.                 ShutWindow();
  115.                 break;
  116.             }
  117.             break;
  118.  
  119.         default:
  120.             break;
  121.         }
  122.     }
  123. }
  124.